package server.controller.api;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import plug.result.RetResponse;
import plug.result.RetResult;
import server.dao.UserSiteDao;
import server.dao.UsersDao;
import server.model.dto.UserDto;
import server.model.entity.UserSite;
import server.model.entity.Users;
import server.service.RedisService;
import server.service.UserService;
import server.tool.tool.EDcrypionUtils;

import java.util.List;

/**
 * 创建人:    xvzhe
 * 创建时间:
 * 修改时间:
 * 版本:      v1.0
 */
@RestController
@RequestMapping("/v2")
@CrossOrigin(origins = "*")
@Api(value = "注册", tags = {"无权限(注册)"})
public class RegistController {
    @Autowired
    private UserService userService;
    @Autowired
    RedisService redisService;
    @Autowired
    UsersDao usersDao;
    @Autowired
    UserSiteDao userSiteDao;


    @PostMapping("/regist")
    @ApiOperation("注册")
    public RetResult regist(@RequestBody UserDto userDto) {
        userService.createUser(userDto, true);
        return RetResponse.makeOKRsp();
    }

    @GetMapping("/registx")
    @ApiOperation("aaa")
    public RetResult registxxxx() {
        List<Users> ut = usersDao.findNoK();
        ut.stream().forEach(item->{
            UserSite us = new UserSite();
            us.setStatus(true);
            us.setPick(true);
            us.setIsDefault(true);
            us.setMobile("自提");
            us.setPeople("自提");
            us.setSite("自提");
            us.setUserId(item.getId());
            userSiteDao.save(us);
        });
        return RetResponse.makeOKRsp();
    }
}
